home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / HyperCuber Source / HyperCuber 2.0 Source.sit / HyperCuber 2.0 Source / CHyperCuberPrefs.cp < prev    next >
Text File  |  1994-05-03  |  11KB  |  384 lines

  1. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. //| CHyperCuberPrefs.cp
  3. //|
  4. //| This implements the HyperCuber preferences.
  5. //|_________________________________________________________
  6.  
  7. #include "CHyperCuberPrefs.h"
  8. #include "CControlsDirector.h"
  9.  
  10.  
  11.  
  12. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. //| CHyperCuberPrefs::IHyperCuberPrefs
  14. //|
  15. //| Purpose: Initialize the preferences and set the to their default values
  16. //|
  17. //| Parameters: none
  18. //|_________________________________________________________________________
  19.  
  20. void CHyperCuberPrefs::IHyperCuberPrefs(void)
  21. {
  22.  
  23.     CPrefs::IPrefs("\pHyperCuber Prefs",            //  Initialize the superclass
  24.                     sizeof(PrefsStruct),
  25.                     CURRENT_PREFS_VERSION);
  26.  
  27.     SetDefaults();                                    //  Set all preferences to default values
  28.     
  29. }    //==== CHyperCuberPrefs::IHyperCuberPrefs() ====\\
  30.     
  31.  
  32.  
  33. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  34. //| CHyperCuberPrefs::SetDefaults
  35. //|
  36. //| Purpose: This sets all preferences to their default values.
  37. //|_________________________________________________________________________
  38.  
  39. void CHyperCuberPrefs::SetDefaults(void)
  40. {
  41.     
  42.     prefs.prefs_version = CURRENT_PREFS_VERSION;    //  Set the version of these preferences
  43.  
  44.     prefs.background_color.red = 0x0000;            //  Initialize the background color
  45.     prefs.background_color.green = 0x0000;
  46.     prefs.background_color.blue = 0x0000;
  47.     
  48.     prefs.left_eye_color.red = 0x0000;                //  Initialize the left eye color
  49.     prefs.left_eye_color.green = 0x7FF0;
  50.     prefs.left_eye_color.blue = 0x0000;
  51.     
  52.     prefs.right_eye_color.red = 0xFFFF;                //  Initialize the right eye color
  53.     prefs.right_eye_color.green = 0x0000;
  54.     prefs.right_eye_color.blue = 0x0000;
  55.  
  56.     prefs.stereo = FALSE;                            //  Don't view in stereo
  57.     prefs.two_image = TRUE;                            //  If view in stereo, use two-image stereo
  58.                                                     //    (otherwise, use two-color stereo)
  59.     prefs.antialias = FALSE;                        //  Don't antialias line segments
  60.     
  61.     Rect rect = {42, 4, 242, 204};                    //  Set default graphics window
  62.     prefs.graphics_window_position = rect;
  63.  
  64.     long controls_window_top = 34;                    //  The first controls window is at the top
  65.     
  66.     long i;
  67.     for (i = 3; i <= MAX_DIMENSION; i++)
  68.         {
  69.         
  70.         Rect window_rect;
  71.         window_rect.top = controls_window_top;        //  Place the controls window
  72.         window_rect.left = 210;
  73.         window_rect.bottom = controls_window_top + i*20 + 5;
  74.         window_rect.right = 4+300;
  75.  
  76.         prefs.controls_window_position[i] =
  77.                                     window_rect;    //  Save this in the prefs
  78.         
  79.         controls_window_top += 20*i + 20;            //  Point to next window top
  80.         
  81.         prefs.controls_window_visible[i] = TRUE;    //  Controls are visible by default
  82.         
  83.         }
  84.     
  85.     SetDefaultKeyCommands();                        //  Set up the default key commands
  86.     SetDefaultMouseCommands();                        //  Set up the default mouse commands
  87.  
  88. }    //==== CHyperCuberPrefs::SetDefaults() ====\\
  89.     
  90.  
  91.  
  92. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  93. //| CHyperCuberPrefs::SetDefaultKeyCommands
  94. //|
  95. //| Purpose: This sets all key commands to their default values.
  96. //|_________________________________________________________________________
  97.  
  98. void CHyperCuberPrefs::SetDefaultKeyCommands(void)
  99. {
  100.  
  101.     long i = 0;
  102.     key_control_struct key;
  103.  
  104.     key.dimension = 3;                    //  Set right arrow to increase 3D angle 1 (longitude)
  105.     key.angle = 1;
  106.     key.increment = 1;
  107.     key.key_code = KeyRightCursor;
  108.     key.modifiers = 0;
  109.     prefs.key_controls[i++] = key;
  110.  
  111.     key.dimension = 3;                    //  Set shift-right arrow to increase 3D angle 1 (longitude) by 10
  112.     key.angle = 1;
  113.     key.increment = 10;
  114.     key.key_code = KeyRightCursor;
  115.     key.modifiers = shiftKey;
  116.     prefs.key_controls[i++] = key;
  117.  
  118.     key.dimension = 3;                    //  Set left arrow to decrease 3D angle 1 (longitude)
  119.     key.angle = 1;
  120.     key.increment = -1;
  121.     key.key_code = KeyLeftCursor;
  122.     key.modifiers = 0;
  123.     prefs.key_controls[i++] = key;
  124.  
  125.     key.dimension = 3;                    //  Set shift-left arrow to decrease 3D angle 1 (longitude) by 10
  126.     key.angle = 1;
  127.     key.increment = -10;
  128.     key.key_code = KeyLeftCursor;
  129.     key.modifiers = shiftKey;
  130.     prefs.key_controls[i++] = key;
  131.  
  132.     key.dimension = 3;                    //  Set up arrow to increase 3D angle 2 (lattitude)
  133.     key.angle = 2;
  134.     key.increment = 1;
  135.     key.key_code = KeyUpCursor;
  136.     key.modifiers = 0;
  137.     prefs.key_controls[i++] = key;
  138.  
  139.     key.dimension = 3;                    //  Set shift-up arrow to increase 3D angle 2 (lattitude) by 10
  140.     key.angle = 2;
  141.     key.increment = 10;
  142.     key.key_code = KeyUpCursor;
  143.     key.modifiers = shiftKey;
  144.     prefs.key_controls[i++] = key;
  145.  
  146.     key.dimension = 3;                    //  Set down arrow to decrease 3D angle 2 (lattitude)
  147.     key.angle = 2;
  148.     key.increment = -1;
  149.     key.key_code = KeyDownCursor;
  150.     key.modifiers = 0;
  151.     prefs.key_controls[i++] = key;
  152.  
  153.     key.dimension = 3;                    //  Set shift-down arrow to decrease 3D angle 2 (lattitude) by 10
  154.     key.angle = 2;
  155.     key.increment = -10;
  156.     key.key_code = KeyDownCursor;
  157.     key.modifiers = shiftKey;
  158.     prefs.key_controls[i++] = key;
  159.  
  160.     key.dimension = 3;                    //  Set / to increase 3D perspective
  161.     key.angle = 0;
  162.     key.increment = 1;
  163.     key.key_code = 0x2C;
  164.     key.modifiers = 0;
  165.     prefs.key_controls[i++] = key;
  166.  
  167.     key.dimension = 3;                    //  Set . to decrease 3D perspective
  168.     key.angle = 0;
  169.     key.increment = -1;
  170.     key.key_code = 0x2F;
  171.     key.modifiers = 0;
  172.     prefs.key_controls[i++] = key;
  173.  
  174.     key.dimension = 4;                    //  Set keypad 9 to increase 4D angle 1
  175.     key.angle = 1;
  176.     key.increment = 1;
  177.     key.key_code = KeyPad9;
  178.     key.modifiers = 0;
  179.     prefs.key_controls[i++] = key;
  180.  
  181.     key.dimension = 4;                    //  Set shift-keypad 9 to increase 4D angle 1 by 10
  182.     key.angle = 1;
  183.     key.increment = 10;
  184.     key.key_code = KeyPad9;
  185.     key.modifiers = shiftKey;
  186.     prefs.key_controls[i++] = key;
  187.  
  188.     key.dimension = 4;                    //  Set keypad 7 to decrease 4D angle 1
  189.     key.angle = 1;
  190.     key.increment = -1;
  191.     key.key_code = KeyPad7;
  192.     key.modifiers = 0;
  193.     prefs.key_controls[i++] = key;
  194.  
  195.     key.dimension = 4;                    //  Set shift-keypad 7 to decrease 4D angle 1 by 10
  196.     key.angle = 1;
  197.     key.increment = -10;
  198.     key.key_code = KeyPad7;
  199.     key.modifiers = shiftKey;
  200.     prefs.key_controls[i++] = key;
  201.  
  202.     key.dimension = 4;                    //  Set keypad 6 to increase 4D angle 2
  203.     key.angle = 2;
  204.     key.increment = 1;
  205.     key.key_code = KeyPad6;
  206.     key.modifiers = 0;
  207.     prefs.key_controls[i++] = key;
  208.  
  209.     key.dimension = 4;                    //  Set shift-keypad 6 to increase 4D angle 2 by 10
  210.     key.angle = 2;
  211.     key.increment = 10;
  212.     key.key_code = KeyPad6;
  213.     key.modifiers = shiftKey;
  214.     prefs.key_controls[i++] = key;
  215.  
  216.     key.dimension = 4;                    //  Set keypad 4 to decrease 4D angle 2
  217.     key.angle = 2;
  218.     key.increment = -1;
  219.     key.key_code = KeyPad4;
  220.     key.modifiers = 0;
  221.     prefs.key_controls[i++] = key;
  222.  
  223.     key.dimension = 4;                    //  Set shift-keypad 4 to decrease 4D angle 2 by 10
  224.     key.angle = 2;
  225.     key.increment = -10;
  226.     key.key_code = KeyPad4;
  227.     key.modifiers = shiftKey;
  228.     prefs.key_controls[i++] = key;
  229.  
  230.     key.dimension = 4;                    //  Set keypad 3 to increase 4D angle 3
  231.     key.angle = 3;
  232.     key.increment = 1;
  233.     key.key_code = KeyPad3;
  234.     key.modifiers = 0;
  235.     prefs.key_controls[i++] = key;
  236.  
  237.     key.dimension = 4;                    //  Set shift-keypad 3 to increase 4D angle 3 by 10
  238.     key.angle = 3;
  239.     key.increment = 10;
  240.     key.key_code = KeyPad3;
  241.     key.modifiers = shiftKey;
  242.     prefs.key_controls[i++] = key;
  243.  
  244.     key.dimension = 4;                    //  Set keypad 1 to decrease 4D angle 3
  245.     key.angle = 3;
  246.     key.increment = -1;
  247.     key.key_code = KeyPad1;
  248.     key.modifiers = 0;
  249.     prefs.key_controls[i++] = key;
  250.  
  251.     key.dimension = 4;                    //  Set shift-keypad 1 to decrease 4D angle 3 by 10
  252.     key.angle = 3;
  253.     key.increment = -10;
  254.     key.key_code = KeyPad1;
  255.     key.modifiers = shiftKey;
  256.     prefs.key_controls[i++] = key;
  257.  
  258.     key.dimension = 4;                    //  Set keypad + to increase 4D perspective
  259.     key.angle = 0;
  260.     key.increment = 1;
  261.     key.key_code = KeyPadPlus;
  262.     key.modifiers = 0;
  263.     prefs.key_controls[i++] = key;
  264.  
  265.     key.dimension = 4;                    //  Set keypad - to decrease 4D perspective
  266.     key.angle = 0;
  267.     key.increment = -1;
  268.     key.key_code = KeyPadMinus;
  269.     key.modifiers = 0;
  270.     prefs.key_controls[i++] = key;
  271.  
  272.     prefs.num_key_controls = i;
  273.  
  274. }    //==== CHyperCuberPrefs::SetDefaultKeyCommands() ====\\
  275.  
  276.  
  277.  
  278. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  279. //| CHyperCuberPrefs::SetDefaultMouseCommands
  280. //|
  281. //| Purpose: This sets all mouse commands to their default values.
  282. //|_________________________________________________________________________
  283.  
  284. void CHyperCuberPrefs::SetDefaultMouseCommands(void)
  285. {
  286.  
  287.     long i = 0;
  288.     mouse_control_struct mouse_control;
  289.  
  290.     mouse_control.dimension = 3;                
  291.     mouse_control.angle = 1;
  292.     mouse_control.horiz = TRUE;
  293.     mouse_control.multiplier = -1;
  294.     mouse_control.modifiers = 0;
  295.     prefs.mouse_controls[i++] = mouse_control;
  296.  
  297.     mouse_control.dimension = 3;                
  298.     mouse_control.angle = 2;
  299.     mouse_control.horiz = FALSE;
  300.     mouse_control.multiplier = -1;
  301.     mouse_control.modifiers = 0;
  302.     prefs.mouse_controls[i++] = mouse_control;
  303.  
  304.     mouse_control.dimension = 4;                
  305.     mouse_control.angle = 1;
  306.     mouse_control.horiz = TRUE;
  307.     mouse_control.multiplier = 1;
  308.     mouse_control.modifiers = shiftKey;
  309.     prefs.mouse_controls[i++] = mouse_control;
  310.  
  311.     mouse_control.dimension = 4;                
  312.     mouse_control.angle = 2;
  313.     mouse_control.horiz = FALSE;
  314.     mouse_control.multiplier = 1;
  315.     mouse_control.modifiers = shiftKey;
  316.     prefs.mouse_controls[i++] = mouse_control;
  317.  
  318.     mouse_control.dimension = 4;                
  319.     mouse_control.angle = 2;
  320.     mouse_control.horiz = TRUE;
  321.     mouse_control.multiplier = 1;
  322.     mouse_control.modifiers = optionKey;
  323.     prefs.mouse_controls[i++] = mouse_control;
  324.  
  325.     mouse_control.dimension = 4;                
  326.     mouse_control.angle = 3;
  327.     mouse_control.horiz = FALSE;
  328.     mouse_control.multiplier = 1;
  329.     mouse_control.modifiers = optionKey;
  330.     prefs.mouse_controls[i++] = mouse_control;
  331.  
  332.     prefs.num_mouse_controls = i;
  333.  
  334. }    //==== CHyperCuberPrefs::SetDefaultMouseCommands() ====\\
  335.  
  336.  
  337.  
  338. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  339. //| CHyperCuberPrefs::GetPrefsPointer
  340. //|
  341. //| Purpose: This returns a pointer to the preferences structure.
  342. //|
  343. //| Parameters: returns pointer to prefs
  344. //|_________________________________________________________________________
  345.  
  346. short *CHyperCuberPrefs::GetPrefsPointer(void)
  347. {
  348.  
  349.     return ((short *) &prefs);            //  Return pointer to prefs structure
  350.  
  351. }    //==== CHyperCuberPrefs::GetPrefsPointer() ====\\
  352.     
  353.  
  354.  
  355. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  356. //| CHyperCuberPrefs::Update
  357. //|
  358. //| Purpose: Update the preferences to match the settings being used.
  359. //|
  360. //| Parameters: none
  361. //|_____________________________________________________________________________
  362.  
  363. void CHyperCuberPrefs::Update(void)
  364. {
  365.  
  366.     Rect        window_position;
  367.     Rect        zoomed_window_position;
  368.  
  369.     //  The prefs structure keeps the current values of the preferences
  370.     //  for the various switches, so no updating is necessary.
  371.  
  372. //    long i;
  373. //    for (i = 3; i <= dimension; i++)        //  Find bounds of controls windows
  374. //        {
  375. //        get_window_rect(
  376. //                ((CControlsDirector *) controls_directors->NthItem(i))->itsWindow,    
  377. //                    &prefs.controls_window_position[i]);
  378. //        }
  379.  
  380. }    //==== CHyperCuberPrefs::Update() ====\\
  381.  
  382.  
  383.  
  384.